package com.tc.controller;

import com.tc.dto.Category;
import com.tc.dto.Result;
import com.tc.myDto.BusinessInformation;
import com.tc.service.HomeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/home")
public class HomeController {

    @Autowired
    private HomeService homeService;

    //获取所有推荐物品
    @GetMapping("/getRecommendShop")
    public Result randomRecommend(){
        return homeService.randomRecommend();
    }

    //根据商家名称获取所有菜品分类
    @GetMapping("/getBusinessInformation/{belongUser}")
    public Result getBusinessInformation(@PathVariable String belongUser){
        return homeService.getBusinessInformation(belongUser);
    }

    //根据分类获取菜品
    @PostMapping("/getFoodByCategory")
    public Result getFoodByCategory(@RequestBody Category category){
        return homeService.getFoodByCategory(category);
    }

    //判断店铺名称是否存在
    @GetMapping("/checkShopName")
    public Boolean checkShopName(@RequestParam String shopName){
        return homeService.checkShopName(shopName);
    }

    //新增店铺
    @PostMapping("/addShop")
    public void  addShop(@RequestBody BusinessInformation businessInformation){
        homeService.addShop(businessInformation);
    }
}
